

use std::{fs::OpenOptions, io::Write};
use std::io::Read;


///
/// 替换文件内容
/// 
pub fn replace_file_context(path:&str,context:String) {
    let mut file = std::fs::File::open(path).unwrap();
    file.write(context.as_bytes()).unwrap();

}

///
/// 
/// 追加写入内容
/// 
pub fn add_file_context(path:&str,context:String) {
    let mut file= OpenOptions::new().create(true).append(true).open(path).unwrap();
    file.write(context.to_string().as_bytes()).unwrap();

}

///
/// 获取文件内容
/// 
pub fn get_file_context(path:&str) -> String{
    let mut content = String::new();
    let mut file = std::fs::File::open(path).unwrap();
    file.read_to_string(&mut content).unwrap();
    return  content;

}